package com.qingke.notlonely.command.factory;

import java.util.HashMap;
import java.util.Map;

import com.qingke.notlonely.command.Command;
import com.qingke.notlonely.command.system.AddUser;
import com.qingke.notlonely.command.system.AddYue;
import com.qingke.notlonely.command.system.AlterUser;
import com.qingke.notlonely.command.system.AlterYue;
import com.qingke.notlonely.command.system.DeleteUser;
import com.qingke.notlonely.command.system.DeleteYue;
import com.qingke.notlonely.command.system.Help;
import com.qingke.notlonely.command.system.ListUserAndEductionByHighestDegree;
import com.qingke.notlonely.command.system.ListUserAndInterestByDegree;
import com.qingke.notlonely.command.system.ListUserByGenderAndAge;
import com.qingke.notlonely.command.system.ListUserByGenderAndBeInvited;
import com.qingke.notlonely.command.system.ListUserByGenderAndInviteTimes;
import com.qingke.notlonely.command.system.ListUserByGenderAndMostBeInvited;
import com.qingke.notlonely.command.system.ListUserByGenderAndMostInviteSuccess;
import com.qingke.notlonely.command.system.ListUserByGenderAndSchool;
import com.qingke.notlonely.command.system.ListUserByGenderAndSchoolAndNonMajor;
import com.qingke.notlonely.command.system.ListUserByHeight;
import com.qingke.notlonely.command.system.ListYueByBeAccepted;

public class SystemCommandFactory extends CommandFactory {
	private static Map<CommandCode,Class<? extends Command>> systemMap=new HashMap<>();
	
	static{
		systemMap.put(CommandCode.ADDUSER, AddUser.class);
		systemMap.put(CommandCode.ADDYUE, AddYue.class);
		systemMap.put(CommandCode.ALTERUSER, AlterUser.class);
		systemMap.put(CommandCode.ALTERYUE, AlterYue.class);
		systemMap.put(CommandCode.DELETEUSER, DeleteUser.class);
		systemMap.put(CommandCode.DELETEYUE, DeleteYue.class);
		systemMap.put(CommandCode.LUAEBHD, ListUserAndEductionByHighestDegree.class);
		systemMap.put(CommandCode.LUAIBD, ListUserAndInterestByDegree.class);
		systemMap.put(CommandCode.LUBGAA, ListUserByGenderAndAge.class);
		systemMap.put(CommandCode.LUBGABI, ListUserByGenderAndBeInvited.class);
		systemMap.put(CommandCode.LUBGAIT, ListUserByGenderAndInviteTimes.class);
		systemMap.put(CommandCode.LUBGAMBI, ListUserByGenderAndMostBeInvited.class);
		systemMap.put(CommandCode.LUBGAMIS, ListUserByGenderAndMostInviteSuccess.class);
		systemMap.put(CommandCode.LUBGAS, ListUserByGenderAndSchool.class);
		systemMap.put(CommandCode.LUBGASANM, ListUserByGenderAndSchoolAndNonMajor.class);
		systemMap.put(CommandCode.LUBH, ListUserByHeight.class);
		systemMap.put(CommandCode.LYBBA, ListYueByBeAccepted.class);
		systemMap.put(CommandCode.HELP, Help.class);
	}
	@Override
	public Command buildCommand(CommandCode cmdCode) {
		Class<? extends Command> commandClass=systemMap.get(cmdCode);
		
		if(commandClass==null)
			return null;
		
		Command command=null;
		try {
			command = commandClass.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return command;
	}

}
